/**
 * @section LICENSE
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details at
 * http://www.gnu.org/copyleft/gpl.html
 */

#ifndef BLOCKDROPPERGAME_H
#define BLOCKDROPPERGAME_H

#include <map>

#include <boost/optional.hpp>

#include <ActionRecord.h>
#include <BlockDropperActions.h>
#include <FreeBlock.h>

namespace BlockDropper
{

struct CellState
{
	CellState(const bool newValue)
		: value(newValue)
		, markDeletion(false)
	{
	}

	bool value;
	bool markDeletion;
};

class BlockDropperGame
{
public:
	BlockDropperGame();
	double clearerPos() const;
	const FreeBlock & freeBlock() const;
	const boost::optional<CellState> & getBoardItem(const Point<unsigned short> & point) const;
	void runOneFrame(const double & time, const BlockDropperActions & actions);

	static const unsigned short width  = 32; // Need to play around with this
	static const unsigned short height = 18;

private:
	double timeOfLastMove = 0.0;
	FreeBlock memberFreeBlock;
	double memberClearerPos = 0.0;
	boost::optional<CellState> board[height][width];
	ActionRecord savedActions;
};

} // end namespace BlockDropper

#endif // BLOCKDROPPERGAME_H

